<?php
/*
 * Created on Jun 29, 2010
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
// 

defined("_ADMIN_") or header("Location:login.php");

# Valori di prova
$_POST['class'] = "fb_test";
$_POST['blogpost_title'] = "Pubblicazione attraverso Vivatech PHPorcupine";
$_POST['blogpost_subtitle'] = "Funziona";
$_POST['blogpost_body'] = "Questo post &egrave; stato effettuato attraverso la pagina di prova di phporcupine!";


import('core.site.Page');
import('core.blog.Blogpost');
import('core.social.Facebook');
import('includes.debug');

require_once(dirname(__FILE__)."/../lib/facebook-platform/php/facebook.php");
//
////echo "<b>Facebook Test page</b>";
$db = getDB();
$user = getUser(&$db);
$blogpost = new Blogpost($db);
$blogpost->doPost($user);

//dumper($blogpost);
//var_dump($db);
$user_fb = $user->getFacebookAccount();
dumper($blogpost);
if($user_fb)
{
	$fb = new PhporcupineFacebook($user);
	$res = $fb->publishBlogpost($blogpost);
//	createFacebook($user);
}
if($res) echo "Pubblicazione facebook ok.";
else echo "Errore nella pubblicazione facebook";
//echo $res;
?>